<script setup>
import request from "@/utils/request";
import { useRouter, useRoute } from "vue-router";
import { onMounted, ref, getCurrentInstance } from "vue";

const router = useRouter();
const route = useRoute();

const { proxy } = getCurrentInstance();

const login = async () => {
  let path = router.currentRoute.value.query;
  console.log("path:", path);
  let redirectUrl = null;
  await request({
    url: "/user/qqLogin",
    params: path,
  })
    .then((res) => {
      if (!res) {
        return;
      }
      console.log("result:", res);
      redirectUrl = res.data || "/";

      if (redirectUrl == "/login") {
        redirectUrl = "/";
      }

      // router.push(redirectUrl);
      window.location.href = redirectUrl;
    })
    .catch((err) => {
      router.push("/login");
    });
};

login();
</script>

<template>
  <div>登录中........,请勿刷新页面！</div>
</template>

<style scoped></style>
